package cn.yhbk.web.modules.manager.Service.Impl;

import cn.yhbk.web.modules.manager.Pojo.Entity.TbCollege;
import cn.yhbk.web.modules.manager.Mapper.TbCollegeMapper;
import cn.yhbk.web.modules.manager.Pojo.VO.College.CollegePag;
import cn.yhbk.web.modules.manager.Pojo.VO.Major.MajorPag;
import cn.yhbk.web.modules.manager.Service.ITbCollegeService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 学院表 服务实现类
 * </p>
 *
 * @author 有何不可
 * @since 2023-08-05
 */
@Service
public class TbCollegeServiceImpl extends ServiceImpl<TbCollegeMapper, TbCollege> implements ITbCollegeService {

    @Autowired
    private TbCollegeMapper tbCollegeMapper;

    @Override
    public TbCollege queryCollegeById(Long id) {
        return tbCollegeMapper.queryCollegeById(id);
    }

    @Override
    public Boolean insertClass(TbCollege tbCollege) {
        return tbCollegeMapper.insertCollege(tbCollege);
    }

    @Override
    public Boolean updateCollegeById(TbCollege tbCollege) {
        return tbCollegeMapper.updateClassById(tbCollege);
    }

    @Override
    public Boolean deleteCollegeById(Long id) {
        return tbCollegeMapper.deleteCollegeById(id);
    }

    @Override
    public CollegePag getCollegeInfoPag(Integer currentPage, Integer pageSize) {
        CollegePag collegePag = new CollegePag();
        collegePag.setPageSize(pageSize);
        collegePag.setCurrentPage(currentPage);
        collegePag.setTotalPage(tbCollegeMapper.queryTotalNum());
        collegePag.setCollegeList(tbCollegeMapper.queryCollegePage((currentPage - 1) * pageSize, pageSize));
        return collegePag;
    }

    @Override
    public TbCollege getByStuOffId(Long adminId) {
        return this.baseMapper.selectOne(new LambdaQueryWrapper<TbCollege>()
            .eq(TbCollege::getStuWorkOfficeId, adminId));
    }
}
